home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
wheels1.arc
/
EXTENDIO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-06-28
|
2KB
|
76 lines
{@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
The purchaser of these procedures and functions may include them in COMPILED
programs freely, but may not sell or give away the source text.
}
{$I filename.typ}
{$I regpack.typ}
{$I errmessg.lib}
{$I extendio.lib}
label
crash;
type
X_type = record
CH : char;
BT : byte;
ING : integer;
end;
var
choice : char;
The_Path : filename_type;
handle, size : integer;
X : X_Type;
N, error_code : byte;
{@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
begin
WriteLn('Let''s create a file. Enter a filename with full path.');
ReadLn(The_Path);
Xrewrite(The_Path,handle,error_code);
if error_code <> 0 then goto crash;
WriteLn(the_path,' has the handle ',handle);
WriteLn;
WriteLn('Now to write some data to the file.');
for N := 1 to 5 do
begin
with X do
begin
CH := chr(N + 64);
BT := N + 10;
ING := 400 - N;
WriteLn(CH,BT:5,ING:10);
end;
XWrite(handle,SizeOf(X),X,error_code);
if error_code <> 0 then goto crash;
end;
WriteLn('Just wrote five records');
WriteLn;
WriteLn('Now how big is that file?');
Xseek(handle,0,sizeOf(X),'E',size,error_code);
if error_code <> 0 then goto crash;
WRiteLn('It has ',size,' records of ',sizeOf(X),' bytes.');
XClose(handle,error_code);
if error_code <> 0 then goto crash;
WriteLn('Now I''l reset that file and read back those records.');
Xreset(The_Path,handle,error_code);
if error_code <> 0 then goto crash;
While error_code = 0 do
begin
Xread(handle,SizeOf(X),X,error_code);
if error_code = 0 then with X do
WriteLn(CH,' ',BT,' ',ING);
end;
Xclose(handle,error_code);
if error_code <> 0 then
writeLn('How can you get an error closing a file?!');
WriteLn('If you''ll let me, I''l erase the file I made.');
WriteLn('Can I? Please?');
read(choice);
if UpCase(choice) = 'Y' then
begin
XErase(The_Path,error_code);
if error_code <> 0 then goto crash;
end;
crash: if error_code <> 0 then WriteLn(message(error_code));
end.